#include <cstdio>

const int N = 1e2 + 5;
int n, m, cnt;
char map[N][N];
int dy[12] = {0, -1, 0, 1, -2, -1, 1, 2, -1, 0, 1, 0};
int dx[12] = {-2, -1, -1, -1, 0, 0, 0, 0, 1, 1, 1, 2};
//:曼哈顿距离:
//  0
// 000
// 00000
// 000
//  0
void dfs(int x, int y) {
  if (map[x][y] == '-') { return; }
  map[x][y] = '-';
  for (int i = 0; i < 12; ++i) {
    int xn = x + dx[i], yn = y + dy[i];
    if (xn > 0 && yn > 0 && xn <= n && yn <= m) { dfs(xn, yn); }
  }
  return;
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("zgg.in", "r", stdin);
  freopen("zgg.out", "w", stdout);
#endif
#endif

  scanf("%d %d", &n, &m);
  char c = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      do
        c = getchar();
      while (c != '-' && c != '#');
      map[i][j] = c;
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (map[i][j] == '#') {
        dfs(i, j);
        cnt++;
      }
    }
  }
  printf("%d", cnt);
  return 0;
}